<?php
/**
 * Tests for Word model
 *
 * PHP version 5
 *
 * @package    TV
 * @subpackage Tests
 * @author     Mike Bevz <mike.bevz@data2people.com>
 * @copyright  2007-2008 (c) Mike Bevz
 * @version    SVN: $Id:  $
 *
 *
 */

/**
 * Includes below
 */
require_once dirname(__FILE__).'/../testsConfig.php';
require_once 'PHPUnit/Framework.php';
require_once 'Zend/Auth/Result.php';

/**
 * Model for message sent to client
 *
 * PHP version 5
 *
 * @package    TV
 * @subpackage Tests
 * @author     Mike Bevz <mike.bevz@data2people.com>
 * @copyright  2007-2008 (c) Mike Bevz
 * @version    SVN: $Id:  $
 *
 */

class WordTests extends PHPUnit_Framework_TestCase
{
    /**
     * Model class
     *
     * @var Word
     */
    private $_model;
    
    
    protected function setUp()
    {
        $this->_model = new Word();
    }

    protected function tearDown()
    {
      unset($this->_model);
    }
    
    public function testSetGetProperties()
    {
        $word = 'testWord';
        $this->_model->word = $word;
        $this->assertEquals($word, $this->_model->word);
    }
    
    /**
     * @expectedException TV_Model_Exception
     *
     */
    public function testGetWordByWordAcceptsOnlyString()
    {
        $this->_model->getWordByWord(array());
    }
    
    public function testGetWordByWordReturnWordObject()
    {
        $expectedValue = 'testWord'.time();
        $this->_model->word = $expectedValue;
        $this->_model->save();
        $oldModel = $this->_model;
        
        unset($this->_model);
        $this->_model = new Word();
        $obj = $this->_model->getWordByWord($expectedValue);
        
        $this->assertEquals($expectedValue, $obj[0]->word);
        
        $oldModel->delete();
    }
      
}